#!/bin/bash
set -e

if [[ $# != 1 ]]; 
then
    echo "Usage: release 1.0.0"
    exit -1
fi

if [ -e dist ]
then
    rm -rf dist
fi

if [ -e library ]
then
    rm -rf library
fi

export VENDOR="qinyi"
export PRODUCT="qinyi_server"
export VERSION=$1

python setup.py py2exe
mkdir library  && cd library
unzip ../dist/library.zip
rm -rf email
cp -r /c/Python25/Lib/email .
cp /c/Python25/Lib/decimal.pyc .

zip -r ../library.zip *
cd ..
mv library.zip ./dist/.

rm -rf library
cd NSIS
makensis qinyi_server.nsi
cd ..
echo "build success!"
